package com.xinminda.dcf.ui.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.xinminda.dcf.utils.TUtil;
import butterknife.ButterKnife;

public abstract class BaseFragment<T extends BasePresenter, E extends BaseModel> extends Fragment {

    private View rootView;
    public T mPresenter;
    public E mModel;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        if(rootView == null){
            rootView = inflater.inflate(getLayoutId(), container,false);
        }
        ButterKnife.bind(this, rootView);
        mPresenter = TUtil.getT(this, 0);
        mModel= TUtil.getT(this,1);
        if(mPresenter!=null){
            mPresenter.mContext=this.getActivity();
        }
        initPresenter();
        initView();
        return rootView;
    }

    protected abstract int getLayoutId();
    protected abstract  void initView();
    public abstract void initPresenter();

    @Override
    public void onDestroyView() {
        super.onDestroyView();

    }
}
